package n2501;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.StringTokenizer;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line=null;
		double speed=0;
		long lastsec=0,sec=0;
		double sum=0;
		while((line=bf.readLine())!=null)
		{
			StringTokenizer st=new StringTokenizer(line);
			if(st.countTokens()==2)
			{
				String time=st.nextToken();
				String ss[]=time.split(":");
				sec=Integer.parseInt(ss[0])*3600+Integer.parseInt(ss[1])*60+Integer.parseInt(ss[2]);
				sum+=speed*(sec-lastsec)/3600;
				speed=Integer.parseInt(st.nextToken());
				lastsec=sec;
			}else {
				String time=st.nextToken();
				String ss[]=time.split(":");
				sec=Integer.parseInt(ss[0])*3600+Integer.parseInt(ss[1])*60+Integer.parseInt(ss[2]);
				double sum2=sum+speed*(sec-lastsec)/3600;
				System.out.println(time+" "+new DecimalFormat("0.00").format(sum2)+" km");
			}
		}
	}

}
